//
//  ProgressView.m
//  mendianjieke
//
//  Created by 响当当 on 7/30/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "ProgressView.h"

@interface ProgressView()
@property (nonatomic, strong)UILabel *firstLabel;
@property (nonatomic, strong)UILabel *waitLabel;

@property (nonatomic, strong)UILabel *loyalTitleLabel;
@property (nonatomic, strong)UILabel *lifeTimeLabel;
@property (nonatomic, strong)UILabel *stateLabel;
@end

@implementation ProgressView

- (UILabel *)firstLabel
{
    if (!_firstLabel)
    {
        _firstLabel = [Utilties creatLabelWithFrame:CGRectMake(-20*kUIScaleBasePlus,10*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                            textAligment:NSTextAlignmentCenter
                                                textClor:LCHexColor(0x000000)
                                                textFont:18*kUIScaleBasePlus];
        _firstLabel.text = @"非会员到店";
    }
    return _firstLabel;
}

- (UILabel *)waitLabel
{
    if (!_waitLabel)
    {
        _waitLabel = [Utilties creatLabelWithFrame:CGRectMake(50*kUIScaleBasePlus,CGRectGetMaxY(self.firstLabel.frame)+11*kUIScaleBasePlus,53*kUIScaleBasePlus,16*kUIScaleBasePlus)
                                            textAligment:NSTextAlignmentCenter
                                                textClor:LCHexColor(0x015AE6)
                                                textFont:11*kUIScaleBasePlus];
        _waitLabel.layer.masksToBounds = YES;
        _waitLabel.layer.cornerRadius = 4;
        _waitLabel.layer.borderWidth = 1;
        _waitLabel.layer.borderColor = LCHexColor(0x015AE6).CGColor;
        _waitLabel.text = @"等待服务";
    }
    return _waitLabel;
}


- (UILabel *)loyalTitleLabel
{
    if (!_loyalTitleLabel)
    {
        _loyalTitleLabel = [Utilties creatLabelWithFrame:CGRectMake(0,0,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                            textAligment:NSTextAlignmentLeft
                                                textClor:LCHexColor(0x999999)
                                                textFont:14*kUIScaleBasePlus];
    }
    return _loyalTitleLabel;
}

- (UILabel *)lifeTimeLabel
{
    if (!_lifeTimeLabel)
    {
        _lifeTimeLabel = [Utilties creatLabelWithFrame:CGRectMake(0,CGRectGetMaxY(self.loyalTitleLabel.frame)+5*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                            textAligment:NSTextAlignmentLeft
                                                textClor:LCHexColor(0x999999)
                                                textFont:14*kUIScaleBasePlus];
    }
    return _lifeTimeLabel;
}

- (UILabel *)stateLabel
{
    if (!_stateLabel)
    {
        _stateLabel = [Utilties creatLabelWithFrame:CGRectMake(0,CGRectGetMaxY(self.lifeTimeLabel.frame)+5*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                            textAligment:NSTextAlignmentLeft
                                                textClor:LCHexColor(0x999999)
                                                textFont:14*kUIScaleBasePlus];
    }
    return _stateLabel;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self addSubview:self.firstLabel];
        [self addSubview:self.waitLabel];
        
        [self addSubview:self.loyalTitleLabel];
        [self addSubview:self.lifeTimeLabel];
        [self addSubview:self.stateLabel];
    }
    return self;
}

- (void)getinfo:(NSArray *)infoArr isFirstTime:(NSInteger)isFirstTime
{
    
    if (isFirstTime)
    {
        self.loyalTitleLabel.hidden = YES;
        self.lifeTimeLabel.hidden = YES;
        self.stateLabel.hidden = YES;

        self.firstLabel.hidden = NO;
        self.waitLabel.hidden = NO;
    }
    else
    {
        self.loyalTitleLabel.hidden = NO;
        self.lifeTimeLabel.hidden = NO;
        self.stateLabel.hidden = NO;

        self.firstLabel.hidden = YES;
        self.waitLabel.hidden = YES;
        
        NSString *loyalStr = infoArr[0];
        NSString *lifeStr = infoArr[1];
        NSString *stateStr = infoArr[2];

        self.loyalTitleLabel.attributedText = [loyalStr addAttriButedString:loyalStr Color:LCHexColor(0x000000) Font:[UIFont systemFontOfSize:14*kUIScaleBasePlus] rang:NSMakeRange(4,loyalStr.length-4)];
           
        self.lifeTimeLabel.attributedText = [lifeStr addAttriButedString:lifeStr Color:LCHexColor(0x000000) Font:[UIFont systemFontOfSize:14*kUIScaleBasePlus] rang:NSMakeRange(5,lifeStr.length-5)];
           
        self.stateLabel.attributedText = [stateStr addAttriButedString:stateStr Color:LCHexColor(0x000000) Font:[UIFont systemFontOfSize:14*kUIScaleBasePlus] rang:NSMakeRange(3,stateStr.length-3)];
    }
   
    
}

@end
